home *** CD-ROM | disk | FTP | other *** search
- const
- cTags = 'ISOSpeedRatings,FNumber,LensInformation';
-
- procedure DumpContent (AContainer: TMacroParam; AWithSave: Boolean);
- var
- i, j: Integer;
- AParam, AElem: TMacroParam;
- ASl: TStringList;
- ASaveDialog: TSaveDialog;
- begin
- ASl := TStringList.Create;
- try
- for i := 0 to AContainer.ArrayContent.Count - 1 do
- begin
- AParam := AContainer.ArrayContent.Items[i];
-
- for j := 0 to AParam.ArrayContent.Count - 1 do
- begin
- AElem := AParam.ArrayContent.Items[j];
-
- // CSV formatted
- ASl.Add ('"' + AParam.ParamName + '","' + AElem.ParamContent + '",' + IntToStr (AElem.Tag));
- end;
- end;
-
- if AWithSave then
- begin
- ASaveDialog := TSaveDialog.Create (nil);
- try
- if ASaveDialog.Execute then
- begin
- ASl.SaveToFile (ASaveDialog.FileName);
-
- Say (Format('Result is saved as %s', [ASaveDialog.FileName]));
- end;
- finally
- ASaveDialog.Free;
- end;
- end;
- finally
- ASl.Free;
- end;
- end;
-
- function PrepareContainer (var AContainer: TMacroParam): Boolean;
- var
- ATif: TTif;
- t, i: Integer;
-
- ATags: TStringList;
-
- AElemContainer: TMacroParam;
- AElem: TMacroParam;
- AVal: Variant;
-
- AXmp: TXMP;
- begin
- result := False;
-
- ATags := TStringList.Create;
-
- AContainer.ParamType := ptBag;
- AContainer.ArrayElementParamType := ptBag;
-
- ATags.CommaText := cTags;
-
- for t := 0 to ATags.Count - 1 do
- begin
- ATags.Strings[t] := Trim (ATags.Strings[t]);
-
- AElemContainer := AContainer.AddArrayElement('');
- AElemContainer.ParamName := ATags.Strings[t];
-
- ATags.Objects[t] := AElemContainer;
- end;
-
- Progress.Cancel := False;
- Progress.useProgress;
- Progress.Max := Selected.Count;
- Progress.Pos := 0;
- Progress.Show;
-
- // process every item
- for i := 0 to Selected.Count - 1 do
- begin
- Progress.ProgressText := Selected.Items[i].FileNameOnly;
- Progress.Pos := i + 1;
-
- ATif := TTif.Create(nil); // the embedded meta processor
- try
- ATif.FileName := Selected.Items[i].ExifFileName;
- if not Selected.Items[i].MediumLoaded then
- begin
- AXmp := TXMP.Create(False);
- try
- Catalog.LoadXMPForImage (Selected.Items[i], AXmp, True);
- AXmp.PushToTif (ATif);
- finally
- AXmp.Free;
- end;
- end
- else
- ATif.Load (True, False);
-
- if ATif.HasExif then
- begin
- for t := 0 to ATags.Count - 1 do
- begin
- AElemContainer := ATags.Objects[t];
-
- AVal := ATif.TagValueByName (ATags.Strings[t], [itBase, itExif, itIPTC, itInterExif, itGps, itMakerNotes], False);
- AElem := AElemContainer.ArrayContent.FindContent (AVal, True);
- if AElem = nil then
- AElem := AElemContainer.AddArrayElement(AVal);
- AElem.Tag := AElem.Tag + 1;
- end;
- end;
- finally
- ATif.Free;
- end;
-
- if Progress.Cancel then
- break;
- end;
-
- result := not Progress.Cancel;
-
- ATags.Free;
-
- Progress.Hide;
- end;
-
-
- var
- AContainer: TMacroParam;
- begin
- if Selected.Count = 0 then
- begin
- Say ('no selection made');
- exit;
- end;
-
- AContainer := TMacroParam.Create(nil);
-
- if not PrepareContainer(AContainer) then
- Say ('Cancelled. You can still save the analysed data up to the moment you cancelled it.');
-
- DumpContent (AContainer, True);
-
- AContainer.Free;
- end;
-